@extends('admin.main')
@section('body')
    <div class="main-title">
        <h2>水票套餐管理</h2>
    </div>

    <!-- 表格列表 -->
    <div class="tb-unit posr">
        <div class="cf">
            <div class="fl">
                <a class="btn" href="{{urlPlat('single','getBillCategoryAdd')}}">新 增</a>
            </div>
        </div>
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">排序</th>
                <th class="">套餐名称</th>
                <th class="">购买数量</th>
                <th class="">赠送数量</th>
                <th class="">额外赠送</th>
                <th class="">状态</th>
                <th class="">创建时间</th>
                <th class="">更新时间</th>
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            @if(count($tree))
                @foreach($tree as $v)
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{{$v['id']}}"/></td>
                        <td>{{$v['sort']}}</td>
                        <td>{{$v['title']}}</td>
                        <td>{{$v['buy_num']}}</td>
                        <td>{{$v['gift_num']}}</td>
                        <td>{{$v['description']}}</td>
                        <td>
                            @if($v['status'] == 1)
                                已启用
                            @else
                                <span style="color: red;">已禁用</span>
                            @endif
                        </td>
                        <td><span>{{$v['created_at']}}</span></td>
                        <td><span>{{$v['updated_at']}}</span></td>
                        <td>
                            <a title="编辑" href="{{urlPlat('single','getBillCategoryEdit',['id'=>$v['id'],'admin_id'=>$v['admin_id']])}}">编辑</a>
                            @if($v['status'] == 1)
                                <a href="{{urlPlat('single','anyChangeBillCategoryStatus',['status'=>0,'ids'=>$v['id']])}}"
                                   class="ajax-get">禁用</a>
                            @else
                                <a href="{{urlPlat('single','anyChangeBillCategoryStatus',['status'=>1,'ids'=>$v['id']])}}"
                                   class="ajax-get">启用</a>
                            @endif
                        </td>
                    </tr>
                @endforeach
            @else
                <td colspan="12" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>

    <!-- /表格列表 -->
@endsection
@section('script')
    <script type="text/javascript">
        (function ($) {
            /* 分类展开收起 */
            $(".category dd").prev().find(".fold i").addClass("icon-unfold")
                    .click(function () {
                        var self = $(this);
                        if (self.hasClass("icon-unfold")) {
                            self.closest("dt").next().slideUp("fast", function () {
                                self.removeClass("icon-unfold").addClass("icon-fold");
                            });
                        } else {
                            self.closest("dt").next().slideDown("fast", function () {
                                self.removeClass("icon-fold").addClass("icon-unfold");
                            });
                        }
                    });

            /* 三级分类删除新增按钮 */
            $(".category dd dd .add-sub").remove();

            /* 实时更新分类信息 */
            $(".category")
                    .on("submit", "form", function () {
                        var self = $(this);
                        $.post(
                                self.attr("action"),
                                self.serialize(),
                                function (data) {
                                    /* 提示信息 */
                                    var name = data.status ? "success" : "error", msg;
                                    msg = self.find(".msg").addClass(name).text(data.info)
                                            .css("display", "inline-block");
                                    setTimeout(function () {
                                        msg.fadeOut(function () {
                                            msg.text("").removeClass(name);
                                        });
                                    }, 1000);
                                },
                                "json"
                        );
                        return false;
                    })
                    .on("focus", "input", function () {
                        $(this).data('param', $(this).closest("form").serialize());

                    })
                    .on("blur", "input", function () {
                        if ($(this).data('param') != $(this).closest("form").serialize()) {
                            $(this).closest("form").submit();
                        }
                    });
        })(jQuery);

    </script>
@endsection
